/*
package com.css.common.core.config;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

*/
/**
 * @ClassName JavaTimeAutoConfiguration
 * @Auther qiumengmeng
 * @Date 2024/7/11 上午12:15
 *//*

@Configuration
@ConditionalOnClass(JavaTimeModule.class)
public class JavaTimeAutoConfiguration {

    private static DateTimeFormatter dateTimeformatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
    DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");

    @Bean
    Jackson2ObjectMapperBuilderCustomizer customizeLocalDateTimeFormat(){
        return jacksonObjectMapperBuilder -> {
            jacksonObjectMapperBuilder.serializerByType(
                    LocalDateTime.class, new LocalDateTimeSerializer(dateTimeformatter));
            jacksonObjectMapperBuilder.deserializerByType(LocalDateTime.class, new LocalDateTimeDeserializer(dateTimeformatter));
            jacksonObjectMapperBuilder.serializerByType(LocalDate.class, new LocalDateSerializer(dateFormatter));
            jacksonObjectMapperBuilder.deserializerByType(LocalDate.class, new CustomLocalDateDeserializer(dateFormatter));
            jacksonObjectMapperBuilder.serializerByType(
                    BigDecimal.class, new JsonSerializer<BigDecimal>() {
                        @Override
                        public void serialize(BigDecimal value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
                            if(value != null){
                                gen.writeNumber(value.stripTrailingZeros().toPlainString());
                            }
                        }
                    });
        };
    }

    class CustomLocalDateDeserializer extends LocalDateDeserializer {

        public CustomLocalDateDeserializer(DateTimeFormatter dtf) {
            super(dtf);
        }

        public CustomLocalDateDeserializer(LocalDateDeserializer base, DateTimeFormatter dtf) {
            super(base, dtf);
        }

        public CustomLocalDateDeserializer(LocalDateDeserializer base, Boolean leniency) {
            super(base, leniency);
        }

        public CustomLocalDateDeserializer(LocalDateDeserializer base, JsonFormat.Shape shape) {
            super(base, shape);
        }

        @Override
        protected LocalDate _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException {
            try{
                return super._fromString(p, ctxt, string0);
            }catch (Exception e){
                return LocalDate.parse(string0 , dateTimeformatter);
            }

        }

        @Override
        protected LocalDateDeserializer withLeniency(Boolean leniency) {
            return new CustomLocalDateDeserializer(this, leniency);
        }

        @Override
        protected LocalDateDeserializer withShape(JsonFormat.Shape shape) { return new CustomLocalDateDeserializer(this, shape); }
    }

}
*/
